package com.hb.controller;

import com.hb.core.base.Result;
import com.hb.core.enums.BaseEnums;
import com.hb.domain.sys.service.ISysDictService;
import com.hb.util.Results;
import com.hb.vo.DictVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:
 * @projectName: zhb-frame-build
 * @author: zhouhaizhi
 * @createTime: 2021/8/26 18:47
 * @version:1.0
 */
@RequestMapping("/dict")
@RestController
@Slf4j
@Api(value = "数据字典", tags = "数据字典")
public class SysDictController {

    @Autowired
    private ISysDictService sysDictService;

    @GetMapping(name = "根据字典类型查询", value = "/type")
    @ApiOperation(value = "根据字典类型查询", notes = "根据字典类型查询")
    @ApiImplicitParam(paramType = "query", name = "dictType", value = "字典类型", required = true, dataType = "Integer")
    public Result<List<DictVO>> queryAllDict(@RequestParam(name = "dictType",required = true) Integer dictType) {
        List<DictVO> list = sysDictService.getListDictByType(dictType);
        return Results.successWithData(list, BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }
}
